program define mcrebinary_glf
args lnf xb a0 a1 tau
tempvar prob


loc p1 "exp(-[1+`tau'*`xb']^(-1/`tau'))"

#delimit ;
quietly generate double `prob' = cond($ML_y1==1, 
	normal(`a0')+(1-normal(`a0')-normal(`a1'))*`p1', 
	1-normal(`a0')-(1-normal(`a0')-normal(`a1'))*`p1' ) 
	if $ML_samp==1;
#delimit cr

if normal(`a0')+normal(`a1') < 1 {
	quietly replace `lnf' = ln(`prob')
}
else {
	qui replace `lnf'=.
}

end
